<template>
  <div style="padding: 20px;background-color: white;">
    <div v-if="top">
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple-dark" style="background-color: #F6F6F6;padding: 10px;">
            <b>基本信息</b>
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <b>隶属类别：</b>省直部门及所属单位
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <b>隶属类型：</b>
            {{ CompanyRes.tagName }}
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple-light">
            <b>上级单位:</b>
            {{CompanyRes.parentName}}
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <b>单位名称：</b>
            {{ CompanyRes.companyName }}
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple-light">
            <b>单位规格：</b>
            {{CompanyRes.xz}}
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <b>单位性质：</b>
            {{CompanyRes.propName}}
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <b>备注信息：</b>
            {{CompanyRes.linkMan}}
          </div>
        </el-col>
      </el-row>
      <br />
      <br />
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple-dark" style="background-color: #F6F6F6;padding: 10px;">
            <b>人员信息</b>
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="5">
          <div class="grid-content bg-purple">
            <b>单位实有人数：</b>
            {{CompanyRes.dwsynum}}人
          </div>
        </el-col>
        <el-col :span="5">
          <div class="grid-content bg-purple">
            <b>单位编制人数：</b>
            {{CompanyRes.rybznum}}人
          </div>
        </el-col>
        <el-col :span="5">
          <div class="grid-content bg-purple">
            <b>定向化岗位人数：</b>
            {{CompanyRes.dxhgwnum}}人
          </div>
        </el-col>
        <!-- <el-col :span="5">
          <div class="grid-content bg-purple">
            <b>离休干部人数：</b>
            {{CompanyRes.lxgbnum}}人
          </div>
        </el-col> -->
        <el-col :span="4">
          <div class="grid-content bg-purple">
            <b> 离退休干部人数:</b>
            {{CompanyRes.lxgbnum + CompanyRes.txgbnum}}人
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="12">
          <div class="grid-content bg-purple">
            <b>在职正省：</b>
            {{CompanyRes.zzzsnum}}人
          </div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple-light">
            <b>在职副省：</b>
            {{CompanyRes.zzfsnum}}人
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="12">
          <div class="grid-content bg-purple">
            <b>离休正省：</b>
            {{CompanyRes.lxzsnum}}人
          </div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple-light">
            <b>离休副省：</b>
            {{CompanyRes.lxfsnum}}人
          </div>
        </el-col>
      </el-row>
      <br />
      <el-row class="erow">
        <el-col :span="12">
          <div class="grid-content bg-purple">
            <b>退休正省：</b>
            {{CompanyRes.txzsnum}}人
          </div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple-light">
            <b>退休副省：</b>
            {{CompanyRes.txfsnum}}人
          </div>
        </el-col>
      </el-row>
      <br />
    </div>
    <div v-if="down">
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple-dark" style="background-color: #F6F6F6;padding: 10px;">
            <b>车辆编制</b>
          </div>
        </el-col>
      </el-row>
      <br />
      <el-table
        :data="Carbz"
        style="width: 100%"
        :border="true"
        :header-cell-style="{background:'#f5f7fa'}"
      >
        <el-table-column label="车辆性质">
          <template slot-scope="scope">
            <span>{{scope.row.nature}}</span>
          </template>
        </el-table-column>
        <el-table-column label="在职省级干部用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.zzsjgbyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.zzsjgbyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="离退休正省级干部用车" align="center">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.ltxzsjgbyc"
              v-if="scope.row.nature == '修改后编制数'"
              type="text"
            ></el-input>
            <span v-else>{{scope.row.ltxzsjgbyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="离休副省级干部用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.lxfsjgbyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.lxfsjgbyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="退休副省级干部用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.txfsjgbyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.txfsjgbyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="定向化实物保障岗位用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.dxhswgwyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.dxhswgwyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="机要通信用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.jytxyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.jytxyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="应急用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.yjbzyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.yjbzyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="机要通信与应急合一用车" align="center">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.jytxyyjhyyc"
              v-if="scope.row.nature == '修改后编制数'"
              type="text"
            ></el-input>
            <span v-else>{{scope.row.jytxyyjhyyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="离退休干部管理机构用车" align="center">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.ltxgbgljgyc"
              v-if="scope.row.nature == '修改后编制数'"
              type="text"
            ></el-input>
            <span v-else>{{scope.row.ltxgbgljgyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="调研视察督察用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.dyscdcyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.dyscdcyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="政务接待用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.zwjdyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.zwjdyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="执法执勤用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.zfzqyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.zfzqyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="特种专业技术用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.tzzyjsyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.tzzyjsyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="业务用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.ywyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.ywyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="班车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.bc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.bc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="后勤服务用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.hqfwyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.hqfwyc}}</span>
          </template>
        </el-table-column>
        <el-table-column label="其他用车" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.qtyc" v-if="scope.row.nature == '修改后编制数'" type="text"></el-input>
            <span v-else>{{scope.row.qtyc}}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div slot="footer" class="dialog-footer" style="margin-top:10px" v-if="edit">
      <el-button type="primary" @click="saveData">确认</el-button>
    </div>
  </div>
</template>

<script>
import { axios } from "@/api/axios";
export default {
  props: {
    id: {
      type: Number,
      default: 0
    },
    top: {
      type: Number,
      default: 1
    },
    down: {
      type: Number,
      default: 1
    },
    edit: {
      type: Number,
      default: 1
    }
  },
  data: function() {
    return {
      CompanyRes: [],
      Carbz: []
    };
  },
  methods: {
    fetchData() {
      axios("/admin/company/viewJson.do", "get", {
        id: this.id
      }).then(data => {
        this.CompanyRes = data.company;
        this.Carbz = [
          {
            nature: "实有车辆数目",
            zzsjgbyc: data.carbz.zzsjgbycSy, //在职省级干部用车
            ltxzsjgbyc: data.carbz.ltxzsjgbycSy, //离退休正省级干部用车
            lxfsjgbyc: data.carbz.lxfsjgbycSy, //离休副省级干部用车
            txfsjgbyc: data.carbz.txfsjgbycSy, //退休副省级干部用车
            dxhswgwyc: data.carbz.dxhswgwycSy, //定向化实物保障岗位用车
            jytxyc: data.carbz.jytxycSy, //机要通信用车
            yjbzyc: data.carbz.yjbzycSy, //应急用车
            jytxyyjhyyc: data.carbz.jytxyyjhyycSy, //机要通信与应急合一用车
            ltxgbgljgyc: data.carbz.ltxgbgljgycSy, //离退休干部管理机构用车
            dyscdcyc: data.carbz.dyscdcycSy, //调研视察督察用车
            zwjdyc: data.carbz.zwjdycSy, //政务接待用车
            zfzqyc: data.carbz.zfzqycSy, //执法执勤用车
            tzzyjsyc: data.carbz.tzzyjsycSy, //特种专业技术用车
            ywyc: data.carbz.ywycSy, //业务用车
            bc: data.carbz.bcSy, //班车
            hqfwyc: data.carbz.hqfwycSy, //后勤服务用车
            qtyc: data.carbz.qtycSy //其他用车
          },
          {
            nature: "现有编制数目",
            zzsjgbyc: data.carbz.zzsjgbycBz, //在职省级干部用车
            ltxzsjgbyc: data.carbz.ltxzsjgbycBz, //离退休正省级干部用车
            lxfsjgbyc: data.carbz.lxfsjgbycBz, //离休副省级干部用车
            txfsjgbyc: data.carbz.txfsjgbycBz, //退休副省级干部用车
            dxhswgwyc: data.carbz.dxhswgwycBz, //定向化实物保障岗位用车
            jytxyc: data.carbz.jytxycBz, //机要通信用车
            yjbzyc: data.carbz.yjbzycBz, //应急用车
            jytxyyjhyyc: data.carbz.jytxyyjhyycBz, //机要通信与应急合一用车
            ltxgbgljgyc: data.carbz.ltxgbgljgycBz, //离退休干部管理机构用车
            dyscdcyc: data.carbz.dyscdcycBz, //调研视察督察用车
            zwjdyc: data.carbz.zwjdycBz, //政务接待用车
            zfzqyc: data.carbz.zfzqycBz, //执法执勤用车
            tzzyjsyc: data.carbz.tzzyjsycBz, //特种专业技术用车
            ywyc: data.carbz.ywycBz, //业务用车
            bc: data.carbz.bcBz, //班车
            hqfwyc: data.carbz.hqfwycBz, //后勤服务用车
            qtyc: data.carbz.qtycBz //其他用车
          },
          {
            nature: "修改后编制数",
            zzsjgbyc: data.carbz.zzsjgbycBz, //在职省级干部用车
            ltxzsjgbyc: data.carbz.ltxzsjgbycBz, //离退休正省级干部用车
            lxfsjgbyc: data.carbz.lxfsjgbycBz, //离休副省级干部用车
            txfsjgbyc: data.carbz.txfsjgbycBz, //退休副省级干部用车
            dxhswgwyc: data.carbz.dxhswgwycBz, //定向化实物保障岗位用车
            jytxyc: data.carbz.jytxycBz, //机要通信用车
            yjbzyc: data.carbz.yjbzycBz, //应急用车
            jytxyyjhyyc: data.carbz.jytxyyjhyycBz, //机要通信与应急合一用车
            ltxgbgljgyc: data.carbz.ltxgbgljgycBz, //离退休干部管理机构用车
            dyscdcyc: data.carbz.dyscdcycBz, //调研视察督察用车
            zwjdyc: data.carbz.zwjdycBz, //政务接待用车
            zfzqyc: data.carbz.zfzqycBz, //执法执勤用车
            tzzyjsyc: data.carbz.tzzyjsycBz, //特种专业技术用车
            ywyc: data.carbz.ywycBz, //业务用车
            bc: data.carbz.bcBz, //班车
            hqfwyc: data.carbz.hqfwycBz, //后勤服务用车
            qtyc: data.carbz.qtycBz //其他用车
          }
        ];
        if (this.edit == 0) {
          this.Carbz.pop();
        }
      });
    },
    saveData() {
      var param = new URLSearchParams();
      var nums = "";
      for (var i in this.Carbz[2]) {
        nums = nums + "," + this.Carbz[2][i];
      }
      var formData = {
        companyId: this.id,
        nums: nums.slice(8)
      };
      for (var key in formData) {
        if (formData[key] instanceof Array) {
          param.append(key, formData[key].join(","));
        } else {
          param.append(
            key,
            typeof formData[key] === "undefined" ? "" : formData[key]
          );
        }
      }
      axios("/admin/carconfig/changeCarconfig.do", "post", param).then(data => {
        if (data.error == 0) {
          this.$message("操作成功");
          this.$emit("close2");
        } else {
          this.$message("操作失败");
        }
      });
    }
  },
  created() {
    this.fetchData();
  }
};
</script>